﻿using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CAD.Service
{
    public static class GeometryExtension
    {
        public static Polyline CreatePolyLine(this List<Point2d> point2ds,bool isClosed=false)
        {
            //Database database = HostApplicationServices.WorkingDatabase;
            Polyline polyline = new Polyline();
            foreach (var point2d in point2ds)
            {
                var index = point2ds.IndexOf(point2d);
                polyline.AddVertexAt(index, point2d, 0, 3, 1); 
            } 
            polyline.Closed = isClosed;
            return polyline;

        }

    }
}
